<?php
/**
 * 进云快速开发框架
 * @apple
 */
define('NOSESSION',true);
require '../../core/core.php';
set_exi(function($message='OK',$type='success'){
	//如果存在错误，此处整理错误日志，后期完善
	if($type!='success'){
		$time=date('Y/m/d H:i:s');
		file_put_contents('error_log.txt',"{$time}\t{$message}\n",FILE_APPEND);
	}
	echo 'success';
	exit;
});
//读取数据
$input = file_get_contents('php://input');
if(!$input){
	exi('数据接收失败~','error');
}
$data=@json_decode($input,true);
if(!$data || !is_array($data)){
	exi('解析数据失败~','error');
}
if(!$data['sign'] || !$data['timestamp']){
	exi('缺少签名或时间戳~','error');
}
$sign=$data['sign'];
unset($data['sign']);
$check_sign=get_sign($data);
if($sign!=$check_sign){
	exi('签名校验失败~','error');
}
$_SESSION['uniacid']=$data['uniacid'];
$_SESSION['uid']=$data['uid'];
$_SESSION['this']='custom';
$_SESSION['pay_result']=$_RQ['pay_result']=json_decode($data['pay_result'],true);
access($data['back_url']);
exi('OK','SUCCESS');